<template>
    <div class="withdrawList-page">
        <van-list 
            v-if="list.length>0"
            :finished="finished"
            v-model="loading"							 
            :error.sync="error" 
            :offset="50"
            :immediate-check="false"
            :finished-text="$i18n.t('default.other.noMore')"
            :error-text="$i18n.t('default.other.errorTip')"
            @load="onLoad"			
        >
        
            <div class="box" v-for="(item,index) in list" :key="index">
                <div class="top">
                    <div class="title value">{{formatDate(item.wTime)}}</div>
                    <div class="value">${{item.wMoney}}</div>
                    <div></div>
                </div>
                <div class="box-bottom">
                    <div v-if="item.wStatus == 1" class="state shz">{{  $i18n.t('default.my.audit') }}</div>
                    <div v-if="item.wStatus == 2" class="state ytx">{{  $i18n.t('default.my.withdrawed') }}</div>
                    <div v-if="item.wStatus == 3" class="state yjj">{{  $i18n.t('default.my.coceard') }}</div>
                </div>
            </div>
            
        </van-list>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                list: [
                    // {wTime:'2024-06-10 1:00:00',ordersPrice:99999.99,ordersState:2},
                    
                ],
                page: 1,
                limit: 10,
                error: false,
                finished: false,
                loading: false,
            }
        },
        mounted () {
            this.getList()
        },
        methods: {
            onLoad () {
                this.getList()
            },
            getList () {
                this.$api.get(this.$url.withdrawal.withdrawal,{
                    page: this.page,
                    limit: this.limit
                }).then(res => {
                   
                    if (res.code == "SUCCESS") {
                        this.loading = false;
                        this.list.push(...res.data.content);
                        if (res.data.content.length < 10) {
                            this.finished = true;
                        } else {
                            this.finished = false;
                        }
                    }
                }).catch(error => {
                    this.error = true;
                })
            },
            formatDate (date) {
                let time = new Date(date)
                let y = time.getFullYear()
                let m = time.getMonth() + 1
                let d = time.getDate()
                let h = time.getHours()
                let mm = time.getMinutes()
                let s = time.getSeconds()
                return y + '-' + m + '-' + d + ' ' + h + ':' + mm + ':' + s
            },
        }
    }
</script>

<style scoped lang="scss">
    .withdrawList-page {
        
        background: #FBF9F6;
        .box {
            padding: .3rem .43rem;
            border-bottom: 1px solid #F0F0F0;
            background: #fff;
            .top {
                display: flex;
                justify-content: space-between;
                align-items: center;
                .title {
                    font-size: .28rem; font-weight: 400;  color: #323232;
                }
                .value {
                    font-size: .28rem; color: #323232;
                }
            }
            .box-bottom {
                margin-top: 10px;
                font-size: 14px; color: #999;
                .shz{
                    color: #B18A4B;
                }
                .ytx{
                    color: #755936;
                }
                .yjj{
                    color: #939393;
                }
            }
        }
    }
</style>